/**
 * Created by jiangtao on 16/6/17.
 */
define(function(require, exports, module) {
    require("LIBS/mockjs/mock.js");
    require("LIBS/iscroll/iscroll-probe.js");
    var me = {
        layout:require("TEMPLATE/common/layout.tpl"),
        element: document.getElementById('app'),
        template: require("TEMPLATE/position/position.tpl"),
        VM:null,
        activeIndex:2,
        init: function(){
            var use = ["render","run"];
            use.forEach(function(name){
                for(var key in this) {
                    if(key == name) {
                        this[key]();
                    };
                };
            }.bind(this));
        },
        render: function(){
            this.VM = layout(this.element,{
                layout:this.layout,
                template:this.template
            });
        },
        run: function(){
            var vm   = this.VM,
                self = this;
            vm.handel.text = "发布职位";
            vm.handel.url  = staticUrl + '/views/index.html?entery=activity/addPosition'
            //分页
            Pagination("#scroll_el",function(d,iscroll){
                console.log(d)
            });
            //监听数据变化
            vm.$watch('activeList.data',function(){

            });
            var mock = Mock.mock(
                {"array|10-30": [{
                    id:2,
                    user:{
                        nickName:"宝宝爱吃鱼",
                        avatar:"../images/head2.jpg"
                    },
                    url:staticUrl + '/views/index.html?entery=position/positionDetail',
                    detail:{
                        imgUrl:"http://docs.ebdoor.com/image/productimage/0/592/5929211_1.jpg",
                    }
                }
                ]}).array;
            var tableData = [
                {name:'定制辅导',data:[],url:staticUrl+'/views/index.html?entery=teacher/index'},
                {name:'精品课程',data:mock,url:staticUrl + '/views/index.html?entery=activity/list'},
                {name:'优质岗位',data:mock,url:staticUrl + '/views/index.html?entery=position/position'}
            ];
            vm.nav = tableData;
            vm.nav[this.activeIndex].active = true;
            vm.activeList.data = tableData[this.activeIndex].data;
        }
    };
    me.init();
});